#include <my_header.h>

/* Usage: ./7_DNS_jd */
int main(void){                                  
    struct addrinfo *res;
    getaddrinfo("jd.com", NULL, NULL, &res);
    printf("京东ip地址\n");
    for(struct addrinfo *p = res; p != NULL; p = p->ai_next)
    {
        struct sockaddr *ipTag = p->ai_addr;
        if(p->ai_family == AF_INET)
        {
            struct sockaddr_in *socketTagV4 = (struct sockaddr_in *)ipTag;
            struct in_addr ipTagV4 = socketTagV4->sin_addr;

            char *strIp = inet_ntoa(ipTagV4);
            printf("Ipv4, ip=%s\n", strIp);
        }
    }
    freeaddrinfo(res);
    return 0;
}


